<script setup lang="ts">
import { onMounted, ref } from 'vue'
import FeatureIcon from '../components/FeatureIcon.vue'
import { useRouter,useRoute } from 'vue-router'
import SL from "../assets/icon/save-svgrepo-com.png"

const route= useRoute()
const router = useRouter()

const messages= ref<any>({})

onMounted(() => {
  window.gamerfinger.getLanguage().then(data => {
    messages.value = data
  })
})

const featureList =  ref([
  {
    name:"sl",
    icon:SL,
    target:"sl"
  },
])

function go(data:any){
  router.push({
    name:data.target
  })
}

onMounted(()=>{
  if(route.meta.needSave){
    window.gamerfinger.saveOpen(route.name as string)
  }
})

function goAbout(){
  router.push({
    name:"about"
  })
}

function goSettings(){
  router.push({
    name:"settings"
  })
}

</script>

<template>
  <div class="wrapper">
    <!-- 展示标题与副标题 -->
    <header class="header">
      <div class="title-glass">
        <h1 class="main-title">Gamer Finger</h1>
        <span class="slogan">{{ messages.slogan || '游戏助手' }}</span>
      </div>
      <div class="settings">
          <div class="setting-icon" @click="goSettings">
            <i class="fas fa-gear"></i>
          </div>
          <div class="about-icon" @click="goAbout">
            <i class="fas fa-info-circle"></i>
          </div>
      </div>
    </header>
    <main>
      <!-- 展示所有支持的功能 -->
      <FeatureIcon v-for="item of featureList" :name="messages[item.name]" :icon="item.icon" @click="go(item)" :title="messages[item.name]"></FeatureIcon>
    </main>
  </div>
</template>

<style scoped>
.wrapper {
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(30, 30, 40, 0.9));
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.header {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  margin-bottom: 32px;
}

.title-glass {
  padding: 24px 48px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.main-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  background: linear-gradient(45deg, #fff, #a9c4c2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.slogan {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  font-weight: 400;
}

.settings {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-icon, .about-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  font-size: 20px;
  color: white;
}

.setting-icon:hover, .about-icon:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.setting-icon:active, .about-icon:active {
  transform: scale(0.95);
  transition: transform 0.1s ease;
}

main {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: 24px 0;
  align-content: flex-start;
}

/* FeatureIcon 组件的玻璃效果适配 */
:deep(.app) {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

:deep(.app:hover) {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
  transform: scale(1.03);
}

/* FontAwesome 图标样式 */
.fas {
  font-size: 20px;
}
</style>